﻿using Compass.Wasm.Shared;
using Compass.Wasm.Shared.Plans;
using System.Net.Http.Json;

namespace Compass.Wasm.Client.Services.Plans;

public interface IPalletService:IBaseService<PalletDto>
{
    Task<ApiResponse<List<PalletDto>>> GetPalletsByPackingListIdAsync(Guid packingListId);
}
public class PalletService:BaseService<PalletDto>,IPalletService
{
    private readonly HttpClient _http;
    private const string ServiceName = "Pallet";
    public PalletService(HttpClient http) : base(http,ServiceName )
    {
        _http = http;
    }

    public Task<ApiResponse<List<PalletDto>>> GetPalletsByPackingListIdAsync(Guid packingListId)
    {
        return _http.GetFromJsonAsync<ApiResponse<List<PalletDto>>>($"api/{ServiceName}/PackingList/{packingListId}")!;
    }
}